﻿<UserControl x:Class="Shoozla.FolderExplorerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="clr-namespace:Shoozla"
             xmlns:sv="clr-namespace:Shoozla.ViewModel"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <DockPanel>
            <TreeView x:Name="foldersTree">
            <TreeView.Resources>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate DataType="ContentPresenter">
                                <StackPanel Orientation="Horizontal">
                                    <Image 
                    Name="img" 
                    Width="20" Height="20" 
                    Stretch="Fill" 
                    />
                                    <TextBlock Text="{Binding}" Margin="5,0" />
                                </StackPanel>

                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                        AncestorType={x:Type TreeViewItem}}, Path=(s:TreeViewItemProps.IsRootLevel)}" Value="True">
                                        <Setter TargetName="img" Property="Source" Value="/Shoozla;component/Images/folder.png" />
                                    </DataTrigger>

                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                        AncestorType={x:Type TreeViewItem}}, Path=(s:TreeViewItemProps.IsRootLevel)}" Value="False">
                                        <Setter TargetName="img" Property="Source" Value="/Shoozla;component/Images/folder.png" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TreeView.Resources>
        </TreeView>
    </DockPanel>
</UserControl>
